package com.zeek.car90s.adapter;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zeek.car90s.R;
import com.zeek.car90s.util.ViewHolder;

import java.util.List;

import static com.zeek.car90s.R.id.tv_game_item;

/**
 * Created by Administrator on 2016/4/7.
 */
public class GameAdapter extends BaseAdapter {

    private List<String> datas;
    private Context context;

    public GameAdapter(List<String> datas, Context context) {
        this.datas = datas;
        this.context = context;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final LinearLayout ll;
        if (convertView == null) {
            ll = (LinearLayout) LayoutInflater.from(this.context).inflate(R.layout.game_gridview_item, null);
        } else {
            ll = (LinearLayout) convertView;
        }

        TextView tvGameItem = ViewHolder.get(ll, tv_game_item);
        tvGameItem.setText(datas.get(position));
//        int level = datas.get(position);
//        if (level > Constants.MAX_UNLOCK_LEVEL) {
//            tvMapItem.setText("");
//            tvMapItem.setBackgroundResource(R.drawable.map_lock);
//        } else {
//            tvMapItem.setText(level + 1 + "");
//            tvMapItem.setBackgroundResource(R.drawable.map_unlock);
//        }


        return ll;
    }
}
